<template>
  <el-select v-model="selectedNetwork" placeholder="请选择所属网点" style="width: 280px" @change="handleChange">
    <el-option v-for="item in networkList" :key="item.id" :label="item.networkName" :value="item.id" />
  </el-select>
</template>

<script>
import { getOutletsList } from '@/api/dashboard'
export default {
  data() {
    return {
      selectedNetwork: '',
      networkList: []
    }
  },
  mounted() {
    this.getOutLet()
  },

  methods: {
    handleChange(val) {
      this.$emit('select', val)
      const networkCode = this.networkList.find(item => item.id === val).networkCode
      console.log('传参', val)
      this.$emit('networkCode', networkCode)
    },
    // 获取网点列表
    getOutLet() {
      getOutletsList().then((res) => {
        if (res.code === 200) {
          this.networkList = res.data
        }
      })
    }
  }
}
</script>
